<template>
	<view class="page page-fill">
		<view class="header">
			<view v-if="userIsLogin">
				<image src="../../static/icons/hot.png" class="face"></image>
			</view>
			<view v-else>
				<image src="http://122.152.205.72:88/group1/M00/00/05/CpoxxFw_-5-AFyVyAABLIH8xBTw233.png" class="face"></image>
			</view>
			<view class="info-wapper" v-if="userIsLogin">
				<view class="nickname">
					{{userInfo.nickname}}
				</view>
				<view class="nav-info">TEL: {{userInfo.username}}</view>
			</view>
			<view class="info-wapper" v-else>
			<!--navigator 登录跳转 -->
				<navigator url="../registerLogin/registerLogin">
					<view class="nickname regist-login">
						登陆/注册
					</view>
				</navigator>
			</view>
			<!-- 这是设置图标按钮 -->
			<view class="set-wapper" v-if="userIsLogin">
				<navigator url="../meInfo/meInfo">
				<image src="../../static/icons/settings.png" class="settings"></image>
				</navigator>
			</view>
		</view>
		<view class="">
			 <uni-list>
			    <uni-list-item  title="个人信息"  thumb="../../static/logo.png"
			     thumb-size="lg"  >
				 </uni-list-item>
				 <uni-list-item title="投诉建议"   thumb="../../static/icons/toushu.png"
				  thumb-size="lg"  >
				  </uni-list-item>
			  <uni-list-item title="关于我们"  thumb="../../static/icons/delete.png"
			 thumb-size="lg"  >
			 </uni-list-item>
			 <uni-list-item title="退出登录" link  thumb="../../static/icons/退出登录.png"
			  thumb-size="lg"  clickable  @click="openOutUsaer" >
			  </uni-list-item>
			</uni-list>
		</view>
		<!-- 退出登录弹窗 -->
		<view class="">
			<uni-popup ref="popup" type="dialog">
			    <uni-popup-dialog mode="base" title="退出登录" message="成功消息" :duration="2000" :before-close="true" @close="close" @confirm="confirm"></uni-popup-dialog>
			</uni-popup>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				//判断用户是否登录
				userIsLogin: false,
				//获取用户登录后缓存中的信息
				userInfo: {}
			}
		},
		//每次打开该页面都会加载一次
		onShow () {
			//获取缓存的用户信息进行切换
			var userInfo = uni.getStorageSync('globalUser');
		    if(userInfo !== null && userInfo !== "" && userInfo !== undefined){
				this.userIsLogin = true;
				this.userInfo = userInfo;
			}else{
				this.userIsLogin = false;
				this.userInfo = {}; //清空数据
			}
			
		},
		methods: {
			 //点击退出登录
			 openOutUsaer(){
				 console.log("outuser")
				 this.$refs.popup.open();
			 },
			  //取消退出登录
			        close(done){
			           uni.showToast({
			               title: '你取消了退出',
			               duration: 2000
			           });
			            done()
			        },
			        //点击确定退出登录 清理缓存
			        confirm(done,value){
				//清理缓存刷新页面
				 uni.removeStorageSync('globalUser');
				 uni.showToast({
				     title: '退出登录',
				     duration: 2000
				 });
				uni.switchTab({
				    url: '../index/index'
				});
			       done()
					
			        }
		}
	}
</script>

<style>
@import url('./me.css')
</style>
